﻿namespace eg_010_变量
{
    internal class Program
    {
        class Rectangle
        {
            public int Width, Height;
            public int TryArea()
            {
                checked
                {
                    int area = Width * Height;
                    return area;
                }
            }
            public int Area() { return Width * Height; }
        }
        static void Main(string[] args)
        {
            Rectangle rect = new Rectangle();
            Console.WriteLine("请输入矩形宽度：");
            // rect.Width = int.Parse(Console.ReadLine());    //从控制台输入数据给矩形的宽赋值
            Console.WriteLine("请输入矩形高度：");
            // rect.Height = int.Parse(Console.ReadLine());   //从控制台输入数据给矩形的高赋值
            Console.WriteLine("矩形面积为：\n{0}", rect.Area());
            Console.WriteLine("矩形面积为：\n{0}", rect.TryArea());
        }
    }
}